package com.kb.design.mapper.postgreSQL;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kb.design.entity.DesignDept;
import com.kb.design.entity.DesignRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色信息表(DesignRole)表数据库访问层
 *
 * @author makejava
 * @since 2024-01-17 15:31:33
 */
@Mapper
public interface DesignRoleMapper extends BaseMapper<DesignRole> {
    @Select("SELECT * FROM \"design_role\" " +
            "LEFT JOIN design_user_role ON design_role.role_id = design_user_role.role_id " +
            "LEFT JOIN design_user ON design_user.\"id\" = design_user_role.user_id " +
            "WHERE design_user.code = #{code}")
    List<DesignRole> queryRoleByCode(@Param("code") String code);
    //SELECT design_dept.* FROM design_user LEFT JOIN design_dept ON design_user.dept_id = design_dept.dept_id WHERE design_user.code = '23988'
    @Select("SELECT design_dept.* FROM design_user LEFT JOIN design_dept ON design_user.dept_id = design_dept.dept_id WHERE design_user.code = #{code}")
    List<DesignDept> queryDeptByCode(@Param("code") String code);
}
